package com.nelson.infraredcontrol.business.home;

import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.nelson.infraredcontrol.R;
import com.nelson.infraredcontrol.base.BaseActivity;
import com.nelson.infraredcontrol.base.Resource;
import com.nelson.infraredcontrol.databinding.ActivityMainBinding;

public class MainActivity extends BaseActivity<ActivityMainBinding> {

    private MainViewModel mViewModel;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_main;
    }

    @Override
    protected void init() {
        mViewModel = new ViewModelProvider(this).get(MainViewModel.class);
        mViewModel.fetchRemoteData().observe(this, new Observer<Resource<Boolean>>() {
            @Override
            public void onChanged(Resource<Boolean> resource) {
                switch (resource.getStatus()) {
                    case LOADING:
                        break;
                    case SUCCESS:
                        break;
                    case ERROR:
                        break;
                }
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        switch (item.getItemId()) {
            case R.id.support_device_choose:
                // 选择不同的设备
                break;
            case R.id.infrared_device_choose:
                // 选择红外发射设备
                break;
        }
        return super.onOptionsItemSelected(item);
    }
}
